//
//  ShippingInformationViewController.m
//  Globalstone
//
//  Created by 辰领科技 on 16/7/11.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "ShippingInformationViewController.h"

@interface ShippingInformationViewController ()
@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIScrollView *scroview;
@property (strong, nonatomic) IBOutlet UILabel *beginTimeLabel;//开船日期
@property (strong, nonatomic) IBOutlet UILabel *totalTimeLabel;//船期
@property (strong, nonatomic) IBOutlet UILabel *ArkVolumeLabel;//柜量
@property (strong, nonatomic) IBOutlet UILabel *numberLabel;//提单号
@property (strong, nonatomic) IBOutlet UILabel *weightLabel;//提单重量
@property (strong, nonatomic) IBOutlet UILabel *locationLabel;//当前位置
@property (strong, nonatomic) IBOutlet UILabel *endTimeLabel;//预计到港时间



@end

@implementation ShippingInformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initViewLayout];
    if ([_type isEqualToString:@"1"]) {
        [self getOrderImportSeaDetail];
    }else{
        [self getOrderExportSeaDetail];
    }
}

- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroview];
    
    self.scroview.contentSize = flexibleSize(CGSizeMake(320, 505), NO);
}

- (IBAction)back:(id)sender {
    [self backBtn];
}

#pragma mark === 进口海运信息
- (void)getOrderImportSeaDetail{
    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    [dic setObject:[Common getLoginInfo][Key_User_userId] forKey:@"museId"];
    [dic setObject:[Common getLoginInfo][Key_User_password] forKey:@"musePwd"];
    [dic setObject:[Common getLoginInfo][Key_User_onlineKey] forKey:@"museOnlineTag"];
    NSString * lan = [InternationalControl userLanguage];
    if ([lan isEqualToString:@"en"]) {
        [dic setObject:@"2" forKey:@"language"];
    }else{
        [dic setObject:@"1" forKey:@"language"];
    }
    [dic setObject:_indentId forKey:@"oimpId"];
    
    self.shareApi.delegate=self;
    [self.shareApi  requestOperationWithDic:dic withPath:GS_queryOrderImportSeaDetail withHttpType:@"POST" withTag:GS_GS_queryOrderImportSeaDetail];
}


#pragma mark === 出口海运信息
- (void)getOrderExportSeaDetail{
    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    [dic setObject:[Common getLoginInfo][Key_User_userId] forKey:@"museId"];
    [dic setObject:[Common getLoginInfo][Key_User_password] forKey:@"musePwd"];
    [dic setObject:[Common getLoginInfo][Key_User_onlineKey] forKey:@"museOnlineTag"];
    NSString * lan = [InternationalControl userLanguage];
    if ([lan isEqualToString:@"en"]) {
        [dic setObject:@"2" forKey:@"language"];
    }else{
        [dic setObject:@"1" forKey:@"language"];
    }
    [dic setObject:_indentId forKey:@"oexpId"];
    
    self.shareApi.delegate=self;
    [self.shareApi  requestOperationWithDic:dic withPath:GS_queryOrderExportSeaDetail withHttpType:@"POST" withTag:GS_GS_queryOrderExportSeaDetail];
}



#pragma   mark---- GetADBanner Request Delegate

-(void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    
    if (tag==GS_GS_queryOrderImportSeaDetail || tag == GS_GS_queryOrderExportSeaDetail) {
        
        if (  [[database valueForKey:@"flag"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
            
        }else  {
            if ([database[@"result"]isEqual:[NSNull null]]) {
                return;
            }
            NSDictionary * dic = database[@"result"];

            if ([_type isEqualToString:@"2"]) {//出口
                _beginTimeLabel.text = [NSString stringWithFormat:@"%@",dic[@"leaveTime"]];
                _totalTimeLabel.text = [NSString stringWithFormat:@"%@",dic[@"dateTime"]];
                _ArkVolumeLabel.text = [NSString stringWithFormat:@"%@",dic[@"containerNum"]];
                _weightLabel.text = [NSString stringWithFormat:@"%@",dic[@"weight"]];
                _locationLabel.text =  [NSString stringWithFormat:@"%@",dic[@"adress"]];
                _endTimeLabel.text =  [NSString stringWithFormat:@"%@",dic[@"arriTimePlan"]];
            }else{
                _locationLabel.text =  [NSString stringWithFormat:@"%@",dic[@"adress"]];
                dic = dic[@"ImportSea"];
                _beginTimeLabel.text = [NSString stringWithFormat:@"%@",dic[@"oiseAboardTime"]];
                _totalTimeLabel.text = [NSString stringWithFormat:@"%@",dic[@"oisePeriod"]];
                _ArkVolumeLabel.text = [NSString stringWithFormat:@"%@",dic[@"oiseContainerNum"]];
                _weightLabel.text = [NSString stringWithFormat:@"%@",dic[@"oiseWeight"]];
                
                _endTimeLabel.text =  [NSString stringWithFormat:@"%@",dic[@"oiseArriveTimePlan"]];
                _numberLabel.text = [NSString stringWithFormat:@"%@",dic[@"oiseBillNo"]];
            }
            
            
        }
    }
}

-(void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
    
    [self dismissWaitDialog];
    
}




@end
